package Offer;

public class Test41 
{

	public static void main(String[] args) 
	{
		int array[]={1,2,4,6,8,9,12};
		findSum(array,13);

	}
   public static void findSum(int[] array,int sum)
   {
	   if(array==null||array.length<2)
		   return;
	   int start=0;
	   int end=array.length-1;
	   while(start<end)
	   {
		   if(array[start]+array[end]<sum)
		   {
			   start++;
		   }
		   else if(array[start]+array[end]>sum)
		   {
			   end--;
		   }
		   else
			   break;
	   }
	   if(start!=end)
	   {
		   System.out.println(array[start]+" "+array[end]);
	   }
   }
}
